#include <cstdio>
using namespace std;

int n, m, k, ans;
bool a[1000001];
int gcd(int x, int y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef DEBUG
	freopen("testdata.in", "r", stdin);
	freopen("testdata.out", "w", stdout);
#endif
#ifndef DEBUG
	freopen("T2.in", "r", stdin);
	freopen("T2.out", "w", stdout);
#endif
#endif
	scanf("%d%d%d", &n, &m, &k);
	k = gcd(n, k);
	int tmp = 0;
	for (int i = 1; i <= m; ++i) {
		scanf("%d", &tmp);
		a[tmp % k] = true;
	}
	if (k == 1) {
		printf("0");
		return 0;
	}
	for (int i = 0; i < k; ++i) {
		if (!a[i]) {
			ans++;
		}
	}
	printf("%d", ans * n / k);
	return 0;
}